<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="  " type="image/x-icon"/>
    <title> AES_DES加密解密.html </title>
</head>
<body>
</body>
<script type="text/javascript" src="crypto-js.min.js"></script>
<script>

    let aseKey = "16120509"     //秘钥必须为：8/16/32位
    let message = "painter";

     //加密
    function encrypt(aseKey,message) {
        return  CryptoJS.AES.encrypt(message, CryptoJS.enc.Utf8.parse(aseKey), {
            mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7
        }).toString();
    }



    //解密
    function decrypt(aseKey,message) {
        return  CryptoJS.AES.decrypt(message, CryptoJS.enc.Utf8.parse(aseKey), {
            mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7
        }).toString(CryptoJS.enc.Utf8);
    }

    // 加密
    let enText = encrypt(aseKey,message)
    console.log(enText)

    // 解密
    let deText = decrypt(aseKey,enText)
    console.log(deText)
</script>
</html>